home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Abalone 1.4.2 / src / Arnold.a < prev    next >
Encoding:
Text File  |  1995-09-21  |  1.5 KB  |  64 lines  |  [TEXT/MPS ]

  1.             SEG        'More'
  2.             DATAREFS    RELATIVE
  3.             
  4.             IMPORT    _neighbour:DATA            ;;    from rules
  5.             IMPORT    _distance:DATA            ;;    from rules
  6.             
  7.             IMPORT    ballVal:DATA            ;;    from own file
  8.             IMPORT    firstTime:DATA            ;;    from own file
  9.             IMPORT    InitArnold:CODE            ;;    from own file
  10.             
  11. Arnold        FUNC    EXPORT
  12.  
  13.             LINK      A6,#$FFFFFFFE
  14.             
  15.             JSR       InitArnold            ;;    Lengthy initialisation in C
  16.             
  17.             movem.l    d3-d6/a2, -(a7)            ;;    save non-temp registers
  18.  
  19. ;;            register initialisation
  20.  
  21.             moveq    #0, d0
  22.             moveq    #0, d2
  23.             moveq    #0, d4
  24.             move    $000e(a6), d6            ;;    !!! IN THINK, OFFSET IS $000C
  25.             movea.l    $0008(a6), a0
  26.             lea.l    ballVal, a1
  27.             lea.l    _neighbour, a2
  28.             
  29.             moveq    #0, d5                    ;;    f = 1
  30. L_1            addq    #7, a2                    ;;    a2 = _neighbour[f][0]
  31.             adda.l    #128, a1                ;;    a1 = ballVal[f][0]
  32.             
  33.             move.b    1(a0, d5.w), d4            ;;    d4 = board->field[f]
  34.             beq.s    L_6                        ;;    if (! (owner = board->field[f])) continue;
  35.             
  36.             moveq    #0, d1
  37.             moveq    #5, d3                    ;;    d = topleft
  38.  
  39. ;;            Most Inner Loop
  40.     
  41. L_3            move.b    0(a2, d3.w), d2            ;;*    d2 = Neighbour (f, d)
  42.             cmp.b    0(a0, d2.w), d4            ;;    if (board->field[Neighbour (f, d)] == owner)
  43.             bne.s    L_4
  44.             bset    d3, d1                    ;;    index |= (1 << d)
  45. L_4            dbra    d3, L_3
  46.             lsl        #1, d1                    ;;    shorts (not bytes).
  47.             
  48.             cmp        d6, d4                    ;;    if (owner == player)
  49.             bne.s    L_5
  50.             add        0(a1, d1.w), d0            ;;        boardValue += ballVal[f][index]
  51.             bra.s    L_6                        ;;    else
  52. L_5            sub        0(a1, d1.w), d0            ;;        boardValue -= ballVal[f][index]
  53.     
  54. L_6            addq    #1, d5
  55.             cmp        #$003d, d5
  56.             blt.s    L_1
  57.             
  58.             movem.l    (a7)+, d3-d6/a2            ;;    restore non-temp registers
  59.  
  60.             UNLK      A6
  61.             RTS
  62.  
  63.         ENDF
  64.         END